package com.cycle.community.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.cycle.community.entity.LoginTicket;
import org.apache.ibatis.annotations.*;

/**
 * @author lenovo
 * @create 2022/8/12 17:04
 */
@Mapper
//不用了
@Deprecated //不推荐使用
public interface LoginTicketMapper extends BaseMapper<LoginTicket> {

    //自动生成主键
//    @Insert({
//            "insert into login_ticket (user_id, ticket, status, expired) "
//            +" values (#{userId},#{ticket},#{status},#{expired});"
//    })
//    @Options(useGeneratedKeys = true,keyProperty = "id")
//    long insertLoginTicket(LoginTicket loginTicket);


    //用ticket查来验证
    @Select("select * from login_ticket where ticket=#{ticket};")
    LoginTicket selectByTicket(String ticket);

    @Update({
            "<script>",
            "update login_ticket set status = #{status} where ticket=#{ticket}",
            "<if test=\"ticket!=null\">",
            "and 1=1 ",
            "</if>",
            "</script>"
    })
    int updateStatus(String ticket, int status);
}
